package config;

import org.redisson.api.RLock;
import org.redisson.api.RedissonClient;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;

public class LockImpl implements  Lock {


    @Autowired
    private RedissonClient redissonClient;

    @Override
    public RLock lock(String lockkey) {

        final RLock lock = redissonClient.getLock(lockkey);
        lock.lock();
        return lock;
    }

    @Override
    public RLock lock(String lockkey, long timeout) {
        final RLock lock = redissonClient.getLock(lockkey);
        return lock;
    }

    @Override
    public RLock lock(String lockkey, long timeout, TimeUnit unit) {
        return null;
    }

    @Override
    public RLock lock(String lockkey, long timeout, TimeUnit unit, long leasetime) {
        return null;
    }

    @Override
    public void unLock(String lockkey) {

    }

    @Override
    public void unLocak(RLock rLock) {

    }

    public static void main(String[] args) throws ExecutionException, InterruptedException {
      /*  final CompletableFuture<Integer> A = CompletableFuture.supplyAsync(() -> {
            return 1;
        });
        final CompletableFuture<Integer> B = CompletableFuture.supplyAsync(() -> {
            return 2;
        });
        final CompletableFuture<Integer> C =  CompletableFuture.supplyAsync(()->{
            return 3;
        });
        
        CompletableFuture.allOf(A,B,C).join();
        final Integer integer = A.get();
        final Integer integer1 = B.get();
        final Integer integer2 = C.get();*/
     //   RestHighLevelclient esClient = new RestHighLevelclient();

    }



}
